﻿using System;
using System.Threading;

namespace eLoop;

static class ThreadRunner
{
    static ThreadRunner()
    {
        var thread = new Thread(OnUpdate);
        thread.IsBackground = true;
        thread.Start();
    }

    private static Action funcs;

    public static void AddRunner(Action func)
    {
        funcs += func;
    }

    private static void OnUpdate(object obj)
    {
        while (true)
        {
            Thread.Sleep(5);
            funcs.Invoke();
        }
    }
}